import Mock from 'mockjs'

export default {
    getMenu: config => {
        const {username, password} = JSON.parse(config.body)
        // 先判断用户是否存在
        // 判断账号和密码是否对应
        if (username === 'admin' && password === 'admin') {
            return {
                code: 200,
                message: 'OK',
                data: {
                    menu: [
                        {
                            path: '/home',
                            name: 'home',
                            label: '首页',
                            icon: 's-home',
                            url: 'home/index'  /*通过url来查找组件所在路径，后序步骤通过这个引入component*/
                        },
                        {
                            path: '/mall',
                            name: 'mall',
                            label: '商品管理',
                            icon: 'video-play',
                            url: 'mall/index'
                        },
                        {
                            path: '/user',
                            name: 'user',
                            label: '用户管理',
                            icon: 'user',
                            url: 'user/index'
                        },
                        {
                            label: '其他',
                            icon: 'location',
                            children: [
                                {
                                    path: '/page-one',
                                    name: 'page-one',
                                    label: '页面1',
                                    icon: 'setting',
                                    url: 'other/PageOne'
                                },
                                {
                                    path: '/page-two',
                                    name: 'page-two',
                                    label: '页面2',
                                    icon: 'setting',
                                    url: 'other/PageTwo'
                                }
                            ]
                        }
                    ],
                    userInfo:{
                        name:'艾希',
                        icon: require('@/assets/images/icon.jpg')
                    },
                    token: Mock.Random.guid(), /*模拟令牌*/
                }
            }
        } else if (username === 'member' && password === 'member') {
            return {
                code: 200,
                message: 'OK',
                data: {
                    menu: [
                        {
                            path: '/home',
                            name: 'home',
                            label: '首页',
                            icon: 's-home',
                            url: 'home/index'
                        },
                        {
                            path: '/mall',
                            name: 'mall',
                            label: '商品管理',
                            icon: 'video-play',
                            url: 'mall/index'
                        }
                    ],
                    userInfo:{
                        name:'源艾希',
                        icon: require('@/assets/images/icon.jpg')
                    },
                    token: Mock.Random.guid(),
                }
            }
        } else {
            return {
                code: 100,
                data: {
                    message: '密码错误'
                }
            }
        }

    }
}
